<? $page_title='部门管理' ?>
<?include "FASHION/page_header.phtml"?>

<ul id="sortable">
<{foreach item=r from=$list}>
<li class="ui-state-default" dept_id="<?$r.id?>">
	<span id="title_<?$r.id?>"><?$r.name?>&nbsp;</span>
	<span class="state-menu">
		<a href="<?url("dept-modify/id/{$r['id']}")?>" class="modify" title="修改信息"></a>
		<a href="javascript:;" onclick="del('<?$r.id?>')" class="remove" title="删除"></a>
	</span>
</li>
<{/foreach}>
</ul>

<input type="button" value="新建" onclick="g2('<?url('dept-add')?>')" />
<input type="button" value="排序" onclick="save_ordered()" />

<div id="dialog" title="新建用户角色" style="display:none;">
	<form action="<?url('dept-save')?>" method="post" id="form1">
		角色名：<input type="text" name="title" id="title" class="text ui-widget-content ui-corner-all" value="" />
		<input type="hidden" name="dept_id" id="dept_id" value="" />
	</form>
</div>

<script>
$("#sortable").sortable();
$("#sortable").disableSelection();

function del(dept_id)
{
	if(confirm('确认删除?'))
	{
		$.get('<?$root?>/dept-delete/dept_id/'+dept_id, function(jsn){
			if(jsn.level=='notice') {
				$("#sortable li[dept_id="+dept_id+"]").remove();
			}
			alert(jsn.message);
		});
	}
}

function save_ordered()
{
	var ary	=	new Array();
	$("#sortable li").each(function(){
		ary.push($(this).attr('dept_id'));
	})
	$.get('<?$root?>/dept-sort/s/'+ary.toString(),function(jsn){
		show_alert(jsn.message);
	});
}
</script>

<?include "FASHION/page_footer.phtml"?>